package com.wendy.common.core.json.jackson;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.annotation.JacksonStdImpl;
import com.fasterxml.jackson.databind.ser.std.StdScalarSerializer;

import java.io.IOException;

/**
 * Standard serializer used for {@link MyAnnotationIntrospector} types.
 *<p>
 * Based on {@link StdScalarSerializer} since the JSON value is
 * scalar (String).
 */
@JacksonStdImpl
public class MyObjectToJsonSerializer extends JsonSerializer<ToJsonObject>
{
    public final static MyObjectToJsonSerializer instance = new MyObjectToJsonSerializer();
    @Override
    public void serialize(ToJsonObject value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
        gen.writeObject(value.getObject());
    }
}
